var url = 'https://www.baidu.com';

var page = require('webpage').create()
phantom.outputEncoding = 'gbk';
page.onResourceRequested = function(request) {
  console.log('Request' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function(response) {
  console.log('Receive' + JSON.stringify(response, undefined, 4));
}
page.open(url, function(status){
  if (status === 'success'){
    var title = page.evaluate(function(){
      return document.title;
    })
    console.log('page title is '+ title)
  }
  phantom.exit()
})